/**
 * Created by Arnald on 2017/5/25.
 */
let publicDao = require('./publicDao.js');

module.exports = publicDao;

publicDao.ranking = function (list, cb) {
    let inList = '("' + list.join('","') + '")';
    let sql = "SELECT " + publicDao.c.pluck + " FROM `" + publicDao.c.table + "` WHERE `bluedId` in " + inList + " " + publicDao.mixOrders() + " " + publicDao.c.limit;

    publicDao.query(sql, cb);

    return this;
};

publicDao.mails = function (ids, cb) {
    let inList = '("' + ids.join('","') + '")';
    let sql = "SELECT " + publicDao.c.pluck + " FROM `" + publicDao.c.table + "` WHERE `id` in " + inList + " " + publicDao.mixOrders() + " " + publicDao.c.limit;

    publicDao.query(sql, cb);

    return this;
};

publicDao.autoAccount = function (cb) {
    publicDao.init().table('user').count(function (err, res) {
        let num = 10000;
        if (res && res[0] && res[0].num) {
            num += res[0].num;
        }
        cb(err, num);
    });

    return this;
};